using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Drawing;

namespace WebComponents.Rss 
{
    // RssHyperLink control - works with RssHttpHandler
    [ToolboxBitmap(typeof(RssHyperLink), "WebComponents.Rss.RssHyperLink.bmp")]
    public class RssHyperLink : HyperLink
    {
        string _channelName;
        bool _includeUserName;

        public RssHyperLink() {
            Text = "RSS";
        }

        // passed to RssHttpHandler
        public string ChannelName {
            get { return _channelName; }
            set { _channelName = value; }
        }

        // when flag is set, the current user'd name is passed to RssHttpHandler
        public bool IncludeUserName {
            get { return _includeUserName; }
            set { _includeUserName = value; }
        }

        protected override void OnPreRender(EventArgs e) {
            string channel = _channelName != null ? _channelName : string.Empty;
            string user = _includeUserName ? Context.User.Identity.Name : string.Empty;
            NavigateUrl = RssHttpHandlerHelper.GenerateChannelLink(NavigateUrl, channel, user);
            base.OnPreRender(e);
        }
    }
}
